package rsvp.util;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;

/**
 * This is an extremely simple logging utility.
 * 
 * It can output to System.out, or to a file, or both. 
 * 
 * If ever we need to move to something more complex, this class can be improved
 * 
 * @author ksz
 *
 */
public class LogUtil extends PrintStream {

	private File m_fLogFile = null;
	
	public LogUtil(File file) throws FileNotFoundException {
		super(file);
		m_fLogFile = file;
	}

	public LogUtil()
	{
		super(System.out);		
	}

	/**
	 * Also print to SystemOutput.
	 * 
	 * @param sLogMessage
	 */
	public void println2(String sLogMessage) {
		println(sLogMessage);
		if (!isSysoutOnly())
			System.out.println(sLogMessage);
	}

	/**
	 * @return true if only sysout (default) is configured for output
	 */
	public boolean isSysoutOnly() {
		return null == m_fLogFile;
	}
}
